<!--
~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="org.wso2.carbon.governance.custom.lifecycles.checklist.ui.processors.InvokeAspectProcessor" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="org.wso2.carbon.registry.extensions.utils.CommonConstants" %>
<%
    try {

        String path = request.getParameter("path");
        String aspect = request.getParameter("aspect");
        String action = request.getParameter("action");
        String callBack = request.getParameter("callBack");
        String mediaType = request.getParameter("mediaType");

%>
<script type="text/javascript" src="../lifecycles/js/lifecycles.js"></script>
<script type="text/javascript">
    proceedAction = function (path, aspect, action, mediaType, callBack) {
        lifecyleOperationStarted = false;

        var versionString = "";
        var obj = document.getElementById('#_comment');

        if (obj.value == null | obj.value.trim == "") {
            showRegistryError(obj.getAttribute("id") + ' ' + org_wso2_carbon_governance_custom_lifecycles_checklist_ui_jsi18n["version.can.not.be.empty"]);
            return;
        }
        versionString = versionString + obj.name + "^^" + obj.value + "^|^";
        invokeAspect(path, aspect, action, callBack, versionString);
    }
    cancelVersionBox = function (path) {
        refreshLifecyclesSection(path);
    }
</script>

<fmt:bundle
        basename="org.wso2.carbon.governance.custom.lifecycles.checklist.ui.i18n.Resources">
    <form id="dependencyVersionFrom" name="dependencyVersion">

        <table class="styledLeft" id="CommentTable">
            <tbody>

            <tr>
                <td colspan="2"><textarea Name="comments" rows="4" cols="20" id="#_comment"></textarea></td>
            </tr>
            <tr>
                <td colspan="2">
                    <input class="button registryWriteOperation" type="button"
                           value="Add Coment"
                           onclick="proceedAction('<%=path%>', '<%=aspect%>', '<%=action%>','<%=mediaType%>'
                                   ,'<%=callBack%>')"/>
                    <input class="button registryWriteOperation" type="button"
                           value="Cancel"
                           onclick="cancelVersionBox('<%=path%>')"/>
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</fmt:bundle>
<%
    } catch (Exception ex) {
        ex.printStackTrace();
        response.setStatus(500);
    %><%=ex.getMessage()%><%
            return;

        }

    %>
